package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.TravelCommentPicture;
import com.ktgj.customer.service.ITravelCommentPictureService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 评论图片Controller
 * 
 * @author ruoyi
 * @date 2022-01-13
 */
@RestController
@RequestMapping("/commentPicture")
public class TravelCommentPictureController extends BaseController
{
    @Autowired
    private ITravelCommentPictureService travelCommentPictureService;

    /**
     * 查询评论图片列表
     */
    @PreAuthorize(hasPermi = "customer:picture:list")
    @GetMapping("/list")
    public TableDataInfo list(TravelCommentPicture travelCommentPicture)
    {
        startPage();
        List<TravelCommentPicture> list = travelCommentPictureService.selectTravelCommentPictureList(travelCommentPicture);
        return getDataTable(list);
    }

    /**
     * 导出评论图片列表
     */
    @PreAuthorize(hasPermi = "customer:picture:export")
    @Log(title = "评论图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TravelCommentPicture travelCommentPicture) throws IOException
    {
        List<TravelCommentPicture> list = travelCommentPictureService.selectTravelCommentPictureList(travelCommentPicture);
        ExcelUtil<TravelCommentPicture> util = new ExcelUtil<TravelCommentPicture>(TravelCommentPicture.class);
        util.exportExcel(response, list, "评论图片数据");
    }

    /**
     * 获取评论图片详细信息
     */
    @PreAuthorize(hasPermi = "customer:picture:query")
    @GetMapping(value = "/{travelCommentPictureId}")
    public AjaxResult getInfo(@PathVariable("travelCommentPictureId") Long travelCommentPictureId)
    {
        return AjaxResult.success(travelCommentPictureService.selectTravelCommentPictureById(travelCommentPictureId));
    }

    /**
     * 新增评论图片
     */
    @PreAuthorize(hasPermi = "customer:picture:add")
    @Log(title = "评论图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TravelCommentPicture travelCommentPicture)
    {
        return toAjax(travelCommentPictureService.insertTravelCommentPicture(travelCommentPicture));
    }

    /**
     * 修改评论图片
     */
    @PreAuthorize(hasPermi = "customer:picture:edit")
    @Log(title = "评论图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelCommentPicture travelCommentPicture)
    {
        return toAjax(travelCommentPictureService.updateTravelCommentPicture(travelCommentPicture));
    }

    /**
     * 删除评论图片
     */
    @PreAuthorize(hasPermi = "customer:picture:remove")
    @Log(title = "评论图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{travelCommentPictureIds}")
    public AjaxResult remove(@PathVariable Long[] travelCommentPictureIds)
    {
        return toAjax(travelCommentPictureService.deleteTravelCommentPictureByIds(travelCommentPictureIds));
    }
}
